﻿using Swashbuckle.AspNetCore.Annotations;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;

namespace Xms.Abp.Application.Dtos;

public class PagedResult<T>: PagedResultDto<T>
{
    public PagedResult()
    {

    }
    public PagedResult(long totalCount, int maxResultCount, int skipedCount, IReadOnlyList<T> items):base(totalCount, items)
    {
        MaxResultCount = maxResultCount;
        SkipedCount = skipedCount;
    }

    [SwaggerSchema("每页最大数量")]
    public int MaxResultCount { get; }
    [SwaggerSchema("跳过数量")]
    public int SkipedCount { get; }
    [SwaggerSchema("分页号")]
    public int PageIndex
    {
        get => SkipedCount / MaxResultCount + 1;
    }
    [SwaggerSchema("分页大小")]
    public int PageSize
    {
        get => MaxResultCount;
    }
    [SwaggerSchema("总页数")]
    public int PageCount
    {
        get
        {
            var v = TotalCount % MaxResultCount > 0 ? 1 : 0;
            return (int)(TotalCount / MaxResultCount) + v;
        }
    }
}
